package com.softkey;

public class SoftKey4 {

	jsyunew3 j9;
	SoftKey4()
	{
		j9=new  jsyunew3();
	}

	private String myhex(byte indata)
	{
		String outString;
		outString=String.format("%X",indata);
		if(outString.length()<2)outString="0"+outString;
		return outString;
	}

	//��ĳ�ֽ�Ϊ�������轫��ת���޷�������
    private  long conver(byte temp){
        long tempInt = (int)temp;
        if(tempInt < 0){
            tempInt += 256;
        }
        return tempInt;
    }

	 //�������ڽ�16�����ַ���ת��Ϊ�޷��ų�����
    private int HexToInt(String s)
    {
        String [] hexch = { "0", "1", "2", "3", "4", "5", "6", "7",
						       "8", "9", "A", "B", "C", "D", "E", "F"};
        int i, j;
        int r, n, k;
        String ch;

        k = 1; r = 0;
        for (i = s.length(); i > 0; i--)
        {
            ch = s.substring(i - 1,  i-1+1);
            n = 0;
            for (j = 0; j < 16; j++)
            {
                if (ch.compareToIgnoreCase(hexch[j]) ==0 )
                {
                    n = j;
                }
            }
            r += (n * k);
            k *= 16;
        }
        return r;
    }


    public String  StrEnc(String InString , String Key)//ʹ����ǿ�㷨�������ַ���
    {

        byte [] b,outb;
        byte []temp_b=InString.getBytes();
        byte [] temp=new byte[8],outtemp=new byte[8];
        int n,i,nlen,outlen;
        String outString;

        nlen = temp_b.length;
        nlen=nlen+1;
        if( nlen < 8 )
            outlen = 8;
        else
            outlen = nlen;
        b=new byte[outlen];
        outb=new byte[outlen];

        for(n=0;n<nlen-1;n++)
        {
        	b[n]=temp_b[n];
        }

        outb=b.clone();

        for( n = 0; n<=outlen - 8 ;n=n+ 8)
        {
            for (i = 0; i < 8; i++) temp[i] = b[i + n];
            EnCode(temp, outtemp, Key);
            for( i = 0 ;i<8;i++) outb[i + n] = outtemp[i];
        }

        outString = "";
        for (n = 0 ;n<= outlen - 1;n++)
        {
            outString = outString +myhex(outb[n]) ;
        }
        return outString;
    }

    public String  StrDec(String InString , String Key)//ʹ����ǿ�㷨�������ַ���
    {

        byte [] b,outb;
        byte [] temp=new byte[8],outtemp=new byte[8];
        int n,i,nlen,outlen;
        String outString,temp_String;


        nlen = InString.length();
        if( nlen < 16 ) outlen = 16;
        outlen = nlen / 2;
        b=new byte[outlen];
        outb=new byte[outlen];

        i = 0;
        for (n = 1 ;n<= nlen ;n=n+2)
        {
            temp_String = InString.substring(n-1, n-1+2);
            b[i] = (byte)HexToInt(temp_String);
            i = i + 1;
        }

        outb=b.clone();

        for( n = 0; n<=outlen - 8 ;n=n+ 8)
        {
            for (i = 0; i < 8; i++) temp[i] = b[i + n];
            DeCode(temp, outtemp, Key);
            for( i = 0 ;i<8;i++) outb[i + n] = outtemp[i];
        }

        outString=new String(outb);
        outString=outString.trim();
        return outString;
    }

	public void EnCode(byte[] inb, byte[] outb,  String Key )
    {

		long cnDelta,y,z,a,b,c,d,temp_2;
		long [] buf=new long[16];
       int n,i,nlen;
       long sum;
       long temp,temp_1;
       long mask=4294967295L;

       //UInt32 temp, temp_1;
       String temp_String ;


       cnDelta = 2654435769L;
       sum = 0;

       nlen = Key.length();
       i = 0;
       for( n = 1 ;n<= nlen ;n=n+2)
       {
           temp_String =Key.substring(n-1, n-1+2);
           buf[i] =HexToInt(temp_String);
           i = i + 1;
       }
       a = 0 ; b = 0 ; c = 0 ; d = 0;
       for(n = 0;n<=3;n++)
       {
           a = (buf[n] << (n * 8)) | a;
           b = (buf[n + 4] << (n * 8)) | b;
           c = (buf[n + 4 + 4] << (n * 8)) | c;
           d = (buf[n + 4 + 4 + 4] << (n * 8)) | d;
       }


       y = 0;
       z = 0;
       for(n = 0;n<=3;n++)
       {
           temp_2 = conver(inb[n]);
           y = (temp_2 << (n * 8)) | y;
           temp_2 = conver(inb[n + 4]);
           z = (temp_2 << (n * 8)) | z;
       }


       n = 32;

       while (n > 0)
       {
           sum = (cnDelta + sum)& mask;

           temp = (z << 4) & mask;
           temp = (temp + a) & mask;
           temp_1 = (z + sum) & mask;
           temp = (temp ^ temp_1) & mask;
           temp_1 = (z >> 5) & mask;
           temp_1 = (temp_1 + b) & mask;
           temp = (temp ^ temp_1) & mask;
           temp = (temp + y) & mask;
           y = temp & mask;
           /*y += ((z << 4) + a) ^ (z + sum) ^ ((z >> 5) + b); */

           temp = (y << 4) & mask;
           temp = (temp + c) & mask;
           temp_1 = (y + sum) & mask;
           temp = (temp ^ temp_1) & mask;
           temp_1 = (y >> 5) & mask;
           temp_1 = (temp_1 + d) & mask;
           temp = (temp ^ temp_1) & mask;
           temp = (z + temp) & mask;
           z = temp & mask;
           /* z += ((y << 4) + c) ^ (y + sum) ^ ((y >> 5) + d); */
           n = n - 1;

       }
       for(n = 0;n<=3;n++)
       {
           outb[n] = (byte)((y >>> (n * 8)) & 255);
           outb[n + 4] =(byte)((z >>> (n * 8)) & 255);
       }
    }

	public void DeCode(byte[] inb, byte[] outb,  String Key )
    {

		long cnDelta,y,z,a,b,c,d,temp_2;
		long [] buf=new long[16];
       int n,i,nlen;
       long sum;
       long temp,temp_1;

       long mask=4294967295L;

       //UInt32 temp, temp_1;
       String temp_String ;


       cnDelta = 2654435769L;
       sum = 3337565984L;

       nlen = Key.length();
       i = 0;
       for( n = 1 ;n<= nlen ;n=n+2)
       {
           temp_String =Key.substring(n-1, n-1+2);
           buf[i] =HexToInt(temp_String);
           i = i + 1;
       }
       a = 0 ; b = 0 ; c = 0 ; d = 0;
       for(n = 0;n<=3;n++)
       {
           a = (buf[n] << (n * 8)) | a;
           b = (buf[n + 4] << (n * 8)) | b;
           c = (buf[n + 4 + 4] << (n * 8)) | c;
           d = (buf[n + 4 + 4 + 4] << (n * 8)) | d;
       }


       y = 0;
       z = 0;
       for(n = 0;n<=3;n++)
       {
           temp_2 = conver(inb[n]);
           y = (temp_2 << (n * 8)) | y;
           temp_2 = conver(inb[n + 4]);
           z = (temp_2 << (n * 8)) | z;
       }


       n = 32;

       while (n > 0)
       {


           temp = (y << 4) & mask;
           temp = (temp + c) & mask;
           temp_1 = (y + sum) & mask;
           temp = (temp ^ temp_1) & mask;
           temp_1 = (y >> 5) & mask;
           temp_1 = (temp_1 + d) & mask;
           temp = (temp ^ temp_1) & mask;
           temp = (z - temp) & mask;
           z = temp & mask;
           /* z += ((y << 4) + c) ^ (y + sum) ^ ((y >> 5) + d); */

           temp = (z << 4) & mask;
           temp = (temp + a) & mask;
           temp_1 = (z + sum) & mask;
           temp = (temp ^ temp_1) & mask;
           temp_1 = (z >> 5) & mask;
           temp_1 = (temp_1 + b) & mask;
           temp = (temp ^ temp_1) & mask;
           temp = (y - temp ) & mask;
           y = temp & mask;
           /*y += ((z << 4) + a) ^ (z + sum) ^ ((z >> 5) + b); */

           sum = (sum-cnDelta)& mask;
           n = n - 1;

       }
       for(n = 0;n<=3;n++)
       {
           outb[n] = (byte)((y >>> (n * 8)) & 255);
           outb[n + 4] =(byte)((z >>> (n * 8)) & 255);
       }
    }

	public  long get_LastError()
	{
		return j9.get_LastError();
	}

	public String FindPort(int start)
    {
        return j9.FindPort(start);
    }

   public int CheckKeyByFindort_2()
    {
        //ʹ����ͨ�㷨һ����ָ���ļ�����
        String DevicePath = ""; //���ڴ�����������ڵ�·��
		DevicePath = j9.FindPort_2(0, 1, 1000139391);
		int ret = (int)j9.get_LastError();
		j9.CloseUsbHandle(DevicePath);
		return ret;
    }


    //ʹ�ô����ȵķ�����ָ���ĵ�ַ��ȡ�ַ���
    private String ReadStringEx(int addr, String DevicePath)
    {
        int nlen, ret;
        byte[] buf = new byte[1];
        //�ȴӵ�ַ0������ǰд����ַ����ĳ���
		ret = j9.YReadEx((short)addr, (short)1, "84DEFA23", "3B0BD32A", DevicePath);
        if (ret != 0) return "";
		nlen = j9.GetBuf(0);
        //�ٶ�ȡ��Ӧ���ȵ��ַ���
		return j9.NewReadString(addr + 1, nlen, "84DEFA23", "3B0BD32A", DevicePath);

    }
    //ʹ�ôӴ�������ȡ��Ӧ���ݵķ�ʽ����Ƿ����ָ���ļ�����
    public int CheckKeyByReadEprom()
    {
        int n, ret;
        String DevicePath = "";//���ڴ�����������ڵ�·��
        String outString = "";
        //@NoUseCode_data return 1;//���û��ʹ��������ܣ�ֱ�ӷ���1
        for (n = 0; n < 255; n++)
        {
            DevicePath= j9.FindPort(n );
            if (j9.get_LastError() != 0) return (int)j9.get_LastError();
			outString = ReadStringEx(0, DevicePath);
			j9.CloseUsbHandle(DevicePath);
			if ((j9.get_LastError() == 0) && (outString.compareTo("ABC") == 0))
			{
				return 0;
			}
        }
        return -92;
    }
    //ʹ����ǿ�㷨һ�����������������������Ч�ط�ֹ����
    public int CheckKeyByEncstring()
    {
        //�Ƽ����ܷ�����������������������������㣬ͬʱ�ڳ����ж�ʹ�ô�����ͬ���ļ������㣬Ȼ����бȽ��жϡ�

        int n, ret;
        String DevicePath = "";//���ڴ�����������ڵ�·��
        String InString;

        //@NoUseKeyEx return 1;//���û��ʹ��������ܣ�ֱ�ӷ���1
        int number1=(int)(Math.random()*65535)+1;
        int number2=(int)(Math.random()*65535)+1;

        InString = (new   Integer(number1)).toString() + (new   Integer(number2)).toString();

        for (n = 0; n < 255; n++)
        {
           DevicePath= j9.FindPort(n );
            if (j9.get_LastError() != 0) return (int)j9.get_LastError();
			if (Sub_CheckKeyByEncString(InString, DevicePath) == 0)
			{
				return 0;
			}
        }
        return -92;
    }

    private int Sub_CheckKeyByEncString(String InString, String DevicePath)
    {
        //ʹ����ǿ�㷨һ���ַ������м���
        int ret;
        String outString = "";
        String outString_2;
		outString = j9.EncString(InString,DevicePath);
		if (j9.get_LastError() != 0) return (int)j9.get_LastError();
		outString_2 = StrEnc(InString, "CC1A6BEFCE7D9F87546C7951EB13BA2B");
        if (outString_2.compareTo(outString) == 0)//�ȽϽ���Ƿ����
        {
            ret = 0;
        }
        else
        {
            ret = -92;
        }
        j9.CloseUsbHandle(DevicePath);
        return ret;
    }

	//ʹ����ǿ�㷨������Ƿ���ڶ�Ӧ�ļ�����
	public int CheckKeyByEncstring_New()
	{
		int n, ret;
		String DevicePath = "";//���ڴ�����������ڵ�·��
		String outString = "";
		int myrnd = (int)(Math.random() * 500);
		String[] EncInString ={ "24012","28716","9052","739","20747","6233","17693","28359","14821","30769","30299","2229","806","30551","2097","17756","5815","14","17367","12561","6050","20789","29864","20932","15376","28752","4640","10503","18254","15233",
"2518","22029","9155","7049","10628","22440","7418","21963","10503","28234","14750","32328","21590","7684","13687","2468","21900","20617","7025","32542","7908","5931","32660","19099","29878","3291","22797","11931","6014","22571",
"31778","22081","3541","19790","13377","1871","3702","12310","32241","29733","2617","5621","24798","11720","22040","26619","27088","13784","30000","1246","17587","12440","697","748","30352","14057","15372","4633","14225","18510",
"10917","32246","27904","23785","28189","20407","17223","6011","9774","4140","26608","5991","31922","10695","25510","27310","20387","27291","5170","8180","31515","9818","18046","30840","17237","30805","28819","14879","24234","9600",
"2974","8553","8084","7786","3558","29560","16045","8519","1238","12304","17583","31721","20216","25489","5236","28097","30198","6398","5367","10723","10395","27640","31567","30974","21712","15042","13498","31590","24990","30781",
"28815","2830","2354","7661","19019","15750","21203","15857","4997","1536","11500","13581","15864","30542","9992","31907","25981","9700","19407","7349","31249","10706","6925","15844","2508","16587","9130","23411","10983","4129",
"15794","5444","1470","1733","25678","8664","32457","24393","12232","24657","165","16864","28554","2675","26120","1629","25630","1694","976","5679","6447","22996","21236","28266","24454","14776","14991","16832","26380","16012",
"31195","14978","30925","13617","12852","23715","20722","4395","4369","1973","6342","32409","6668","6377","177","5184","4322","11538","31294","9600","874","674","4632","13403","29598","31657","27143","885","8603","16348",
"21239","18445","30104","32395","1777","31751","2546","20649","799","20453","21791","15048","459","15561","29628","20249","5215","13941","4738","28527","23909","32073","30795","12092","27271","4170","12306","21905","11921","16152",
"21231","32544","7017","23542","29213","24637","23580","3526","8439","9944","11987","16904","7926","31875","24280","16097","8628","10354","24213","21777","16107","20853","405","12796","30325","24574","22144","20897","23628","33",
"8482","4261","25226","17293","29795","24135","17258","25494","27727","3692","2885","9007","2064","19347","17045","20711","9198","10465","14324","26866","4948","21526","27163","22306","23244","26517","4583","22761","2561","23648",
"19535","32600","13755","7193","25710","20770","4582","13056","15743","3225","11147","8698","23770","2478","17108","20614","5116","15347","17675","7882","19067","21659","26266","6020","26644","1145","23819","16920","24224","24059",
"14601","5255","21530","22327","24668","1397","27802","27614","10224","15905","13404","24386","3534","27759","10681","7764","4896","13538","26410","16806","13872","17561","27979","12140","3177","857","3286","23925","31826","25985",
"28834","13110","6041","24086","18349","3008","5382","28856","3855","22467","27266","25514","31744","24467","1818","4558","1503","9507","11508","23717","4129","26114","27485","15953","13411","15716","14527","31637","11358","26139",
"11426","30163","23532","7321","22961","7438","31495","8431","18359","485","24522","22735","3485","1948","26733","4493","2925","13844","1357","25113","17488","11216","25312","11526","22674","12274","13251","17029","8093","25659",
"6831","8809","25081","5902","13438","24099","13138","13676","16938","6855","27760","23800","29389","13060","17727","3573","19874","31022","3784","32065","15362","6456","3381","1635","13159","6833","29136","15738","32618","718",
"29955","8520","11208","5727","4185","27951","3672","15318","22650","2868","28949","32069","30513","9717","23577","10849","17769","23221","32671","6776" };
		String[] EncOutString ={ "DC83620E637338B1","F87D220953827947","B7A0AD4969A2C5BD","DCA1596DA61F4F15","4D08D90CF9BD20D1","EA4D73305F71F91D","D479D8FDFB5F91D0","BCD9A141F97B5271","8FEC6FDCF8BA90A8","2D6B96DFBCA57297","07C29A7E4E4462E6","334479A2DA2F3B36","8C8CB29A0629F148","485BE18DD26EECE7","5354382AD67A3740","A1EBED60DDBFC786","E9170810681DAD31","52729AADCC33E135","63FEDA9BF1748199","A84A7334A716408C","248DC8981A3765B2","32BEA94AB6D5C818","F33518E7F49FC127","80F7615CF40B2EEB","83D8F2D7580B20A2","7B345EDFEA21ED1A","EFA20114F4D1ECDE","2BD8290F60D9ABE8","F358CF438C97DDDA","326970E6FA820B59",
"564E9CBE64537CBB","F4FC490D627702A5","2355809B192285B4","3F6F0FB303408A22","FE5410C4B4C632DF","53536640059003FE","78E7804768150369","3F9521F5C856B873","2BD8290F60D9ABE8","342BCB179115DB5F","7EC36CDE1ACD92AE","E7FEB8C17273CE7B","0878EA5622605861","5E747B1679EB0D5B","28E509C9872B5192","4A2A8E37713F7BD1","76F6E95849163391","EE800DF21D73F1ED","CCF01E785FDC0256","A137338A73F64C5D","26F9570FCEA28C1B","2D12C20607ED71F7","62D8322A193E8A93","A57A6E553F5B05AC","798DD480B9298109","A22B05AEB3478CF2","E48B66BF7C273B22","24F2046231770025","54D3CB8A44DF2D30","CFD6E1166510A6F8",
"AA9AF06F8740DCBE","4F59CFD5CD392A50","928F1A17C82C6D1F","D2BD4F40DEADEF89","43D4C9B6583D1A1F","7D9C18A632A90915","58D078BA34F9BC6E","D109067559C45A43","CB93E2D5BF47A75D","12B3247DF9B0153A","53D9A472BA3AEB5C","AB58753DD9A35A18","5ADB5F56A254416F","B79C964BDEDB07C6","65A04608623D7D57","7625B6CA78FFFF75","621E0DED2B383FE9","F26406E686319F5D","58826008E042E59F","8A41800FC2F54A0C","6ECDE6B9F0CCBC04","8806F56E5F2CC660","815135E6EE8AC688","D8792734A73BBEDF","A2B995E35218C96D","2961BAF0A10FA755","0296A9594E22F7FC","5973652B452CF75F","EE637A6AE48CB72B","B7879B5CFB364EDC",
"E0845749AEE4329B","8C043525BCBD567F","9DBFE48EC651369B","22CA2AE68D53C894","2E28E24FB22335CE","A28DD0EA29039A81","C13017AF17B5B405","AC41943D6A949AD2","8A33637105E45854","EC79EE92763F679D","9B162BA5AE81E71E","D3713B78AAAE2330","F74EDC664A873EDF","25C4870B894E91D2","4050CADE982D2A4E","4E7B814F1B9BF835","D7DE728FAF263811","5BE90ED957651AA2","64599F80440449AF","61B44AF2434CDA64","E600D22EA7B672CA","D6974E8F0DCC0174","091C7306743E8CE5","FF1BCAA1F215E2C6","4F3D08B3BBFBC598","53C4A721B54118D4","D18000C44F250AB0","909CF904D54818BF","81670395CED623AE","78BDA53271D8D177",
"16E30C9826E9380D","300C856E308A2FE7","7594992308DCA6BF","5C9C5B85D8C7D93D","05EC1FF3611171CF","7403DBD24ACFA4D0","BE4A1D924F4E11DF","A7D0DEFCFB7228D5","13FAA53D971C2724","6EBBFB7526CA8CDD","0D1CF25E3EA4D8D6","3BDCFF6AD253EB0C","235C4E45FC43AD94","9077E4679630CD5C","43D108044BFDA6A9","B24C06D98E118BFF","31D7CEF0F0D14EC2","F37ED737D650AF8F","05B554C4C0A1DA82","1FECDBEE876AB811","2F2C1BB12F5BEFC8","43B145ADE98012B5","8DC4D402A32916A8","AD8F3F23BBA3AD1F","DB3940D7C4463A7B","C5F71EADA06C5EC8","E99199AB12965F42","851CDA0EE1664845","EE72357DDD9F6788","034F60DFA68B28E4",
"C59616B7AFCE997E","BC57BA14706BDAEB","B24C082609B0B108","CAFBDD9A01162CC5","24BAAA548B7F6197","83E26F147B3E0EB7","B82A2217D82304AC","5FB052E18868054F","989EB853E7FF80DE","AF7413B33ED467C3","99C78935A5C61D53","C75B21B14C422E8C","BC07B3B3BC1B9247","EAAE5BC305C130AA","FCDA8EF3E01267D3","7B200D546EF219A8","7D5AB5E634B12A00","A5EDCF54328E8085","2D30D0A866E41484","649FAC384DB5494A","3076C822307938D8","A72CC8C8A61FF816","0D4FFDB639B572A8","25634F7C25698CC8","D4A4BE9598C760E8","CB29966E3D5F301A","4B63E93D2BFBF627","A2AC3BA24162C8D3","6840ECE74FC17CB0","B111A678545362D8",
"BFCCB4F3045095CD","7A79E588812B22FC","1466AF429738CFC9","2744CBD8A52EA371","FD3D4B0F7C212275","709102F7FCDF5C0A","9055F1199FA781B8","F5CA72D3615B7A64","C31B34AFC68B5831","C5C08E6E1075CCA3","E28135C5627BC08E","89E989ADD5C3D937","474BD57703B1F3C2","4933A389F261A84C","7C88D3030025AB3E","7E55FB649092CD1C","FE5CD31BF54710ED","625420812DA81565","61A87AAF24A8B81A","4DE18FF5574728BF","B0E3607D982EFF02","3AB09AC81C2F7A0D","DDC6A1FF0124E154","D7B6AC1E28CF024D","C64CF7C38A8C32C5","05224EBF331AAC89","DAC2412E1C0CB0A7","1B4B956262FADF21","2C09DB74D136E6AC","16704320EF72EDE8",
"DA07D9817A3D62B7","4CA04ED170F54526","09A0C9E10C5E6443","572FA68B1CB33833","6DFE8BD0BB36C680","E178E9E4D63F38B1","6AEB6779295E4C89","F4CED721FC2AE1EC","5BC3BF5E3F297E5A","9A269CCA45CDC035","6B47CCEEE5DD8A2A","C3D503F394E183D6","321E9807E1BE8233","4388FD54FA6B17B7","FF69CF7403592BF1","2FBDDEC27D2BDF3B","E00217235C076E8C","19947E0732FCFCA4","30E5DCE3858B5376","78BDA53271D8D177","17412D55053857F9","DCDA14832B70FE60","76AE9610EF6C7E27","9C4DDC0A66F8E1DB","266C2BEED287A790","FF3D8A2813116E19","64B43F863F29643D","C2E0B2892FA40157","87A94CEC4B1B102D","BA144C14CBADA36D",
"D6FB7372B8FA2654","59CA618F5677FA77","02EC4397C50BDD85","19EBBA48B7A517F7","27D10E6753716C65","9A37F8D66A0D475D","AD26C58A78CF8702","C02849D77431CCD2","2C4E2B6A86EEAC11","201FC08F70559308","6504188274F45D1E","FB5229E3EAB9F26A","102835B5283E92BC","F610D4C55ED23F80","BBBFF658B0F9F010","4618421F4B5505A1","1D96B5C8B7A5D208","C489F26C93923488","294B2DB6AC06438F","BD47242F62F93538","215671BFC2433EEB","2C2C711C017CC87C","B9E24E88548224EE","C49BA6466F5E9F29","38CB31140C5D108D","205B3AEF9DFC25B6","4467BF222EBB30DE","18BB9D3AF7058314","484C4ECD9678A5E4","9B971645EBDDC158",
"E8953590F6FD485B","815E60D62858D343","A0803FA0B8969F1D","4BD566909992FB76","ECD10FA3206DC997","49C7792D8DE1DB11","DD76F5D337B95B6D","89B7AC3E3BD87F3C","8EC2D001990ADBFE","B667A239C0008F6C","15A16BEFAF17F83C","C1BE089BB9AD3F6A","BB7CA13BFC467FDD","C4BF1FD685CC6710","A5507AB13DBF7D07","FA4E7CC835C1F7AD","3A9451F141E0DBC9","30AD6A268A274DC3","6DC4869FBFBDC53C","C2E4C05C05BEED7F","6103ABDA6714D047","904122EC2E5E1BFB","43AD919569502ABE","14168C5410083DD9","9C9B8048DBF48AE1","978E67B20C8F2B01","ED13CF2B82390F34","049D494D8379FD61","7651D9D7B2E7F305","A01D234B29C5EBE2",
"FCDD75597FB35583","BEF9281987E60126","2F284B3E21843F8E","BA2FFFE22F213894","36C3C7EAEC75F5E1","407A86C96B3E0EEB","74E369771CFFBA40","B6CDA7118A6B272D","48F33644CA74F3FC","84DE5BEB09A46CC8","2A6F8AFC0DCC49DA","BD838C1EAC0928E8","4CFB7A266DCE1D30","56FB3301A1F73503","EE37A14DA460B657","2BF27A8790761BB3","B16F0D1ADB175528","1CC6742E473B1A23","B748166435376B9B","C8CBFFDAF343BE7B","383379C962AFE999","A5154F14EC33B0DA","31224E9BC663F257","0C99BCAB43D7F51B","8A48AF36049917CD","FD5A0362208E7527","014021AFEDC468C0","F613B64563C54DBE","B006A59E9CEF45E0","6A5E28635DF70A7F",
"88079FC793277C00","2CFC57BF4E33698E","CC9B8B1FDC19F382","B768C930203C6B8F","BF965DD998436D77","E63778616ACB3B23","97E36DAFBD4D45EC","A68B1BC8C25C3B24","C6235B07347FB9B2","327AEA65FC7E81A1","CDD0B4AF6F6225F5","C17F5E16D4E00B27","7794A66316D6931C","97B226993BB476B8","3F015E0BFE4168ED","D513D59831D5225E","495BD55621F06B1F","A85860374C43EF2F","45F1C800AC5E6B74","0C872A897C380470","08278FA93C2F3AB2","748A7E18635EB36F","9105C1658DA0671C","B1BD0C652932FB9B","600B4001DD3B7470","E73C7B095ED340DC","F32AE90B7460CD31","38FBC8DC5E4BA352","589120853A4EE289","663D98D72D94BF62",
"65448F6246BA1712","63DD1DD0C7EDE136","C6EC702CE5BEB27B","D1C0B2360E580AC5","36C97C671444625C","CC9136DD0C7C3BF0","F1BB877A66B8E53D","833E7A3988BA3CD0","46B17B09B71F97A4","E2B85C338610956E","A1D95A6BF0150BE3","7EA006ACAC2C7CE4","19396059F8A77B58","35AE00833D7A29FE","AEF966BB9D596E94","34C9CCAB4C476E5F","1B0EFAD65AAD96EE","FC8AFB00E5038E7A","877C670F10ED54C6","594C3B39E0311243","EC2899CF44B81317","6661ED827E24F5F6","75A142A554EA4F64","410711F010CFEEE9","1332BA9943B58023","10451E91EE1D512E","20E67650374A10E4","AF1088A6157B6D27","BFA7F4711391920E","EFC666F5EAA980CE",
"322321A26C1C2EE9","D39C72AD980DB237","8AEF7D9CF2466385","BC4729AA0E338C23","DDB79E1A8AB256D5","1BBAC7BE1B2DC6CD","6B96FA61FB06497B","D9488E09B5C9B46B","11BC187A03706D46","F6021773DEB0A9C8","F720AE137914CFA6","D8DA9D3F8E415915","CB2171AC81F377B9","62F5487208F11F31","41AA7DC5B2F66CDD","B99AE8E8C4909492","2AA165F930514FB7","78D75B5549C129A1","15CB0BF3E18AB2B4","2AC76F944867FEB2","B111A678545362D8","7DEEC968D73BAF3D","001C187D2EB435D7","6513844269E084F7","2CAC4C2112CF4D14","0CDFA681726F220B","5FF82F64EB0531FF","8EB26C21B3635391","6C5ECA1119CA0A49","B69AC0F3DB808217",
"FB2D05B110914479","44A3F1074C806C49","5E2752406E17ABED","BD978A7749BD6733","9D355FC9065F4965","A1113E223CA2BC5C","212B4752815949B6","920CF4A3040EE54B","6BEE2D42B108923C","530F99C0EF39F253","C43DBD504320F3C3","3E199E3273902F70","0C0E40240F0F5EDE","3EEFDFC89252849C","17E2F8DB49C870FE","AF694CAAE61B88B6","5E46AD69E7E39D49","75CB22D2919A7E21","723B3DC005F469A4","A9AAFC27A2AFDD1B","5964081D562B3016","001665633B60574A","089631B948B74AB7","CDBA4701238BDC82","92DA50117BDEBDDC","F0580A7B59C855F2","A7C839B58CF88FB5","0A876F5E5240B3C8","3B30DD4533089920","2037B6FE9EB582FD",
"2A1555C77E7CBFD1","81A2D2FA2122D2BD","17E5F4D9091E1F87","B2F7B4658F6BB847","E4917622324DB756","41DAA5661AD3D0DA","74E1C7A853213EDF","03DB44FF5BB75034","466ABD50E19C4F55","54ECFCEE3A08D92B","3D5BDB9476ACB838","A0EE7E47834C625A","5D2BA59B8DB5CD97","9E619060142064F0","09C9396D3394ABFE","6793C705EF1A12CB","BB6C44B872EDC2A0","C7CA9BFA4D74A192","208B9D8CB2533E8C","E3D920D2DEF5A13B","5266E57E20BA8F28","79F489268B415E93","4441F5E4FAE97195","424BFF825988B12D","1EF3D39D02AF20BB","454D353F1D258F1A","BDA2E3F750313C4B","ADA4C1A8DB256CBB","911770FD07D01BCA","D5C9A38AE7CFA6AC",
"B5F6F3F534C3F2FC","A716445F46DA378A","22464F1769284BBE","2C7055D094BCC928","450696F71ED8536B","9BF3B59301013D8E","84A4022E66D70142","B5284F143AFF2EF4","24B273AD649FE54D","E01B98F39AB00860","16DBF0DCB4365011","EE768422209F3DB7","FBB86D7ABBF7E5F2","B470E8108840F234","946609F54ADA4B93","1719AD6AAE50542E","5F0EA24A5EE229A2","18AD4600737AE587","EA64A90847891A15","10255CB2138F3813" };
		//@NoUseNewKeyEx return 1;//���û��ʹ��������ܣ�ֱ�ӷ���1
		//@NoSupNewKeyEx  return 2;//���������֧��������ܣ�ֱ�ӷ���2


		for (n = 0; n < 255; n++)
		{
			DevicePath = j9.FindPort(n);
			if (j9.get_LastError() != 0) return (int)j9.get_LastError();
			outString = j9.EncString_New(EncInString[myrnd], DevicePath);
			j9.CloseUsbHandle(DevicePath);
			if ((j9.get_LastError() == 0) && (outString.compareTo(EncOutString[myrnd]) == 0))
			{
				return 0;
			}
		}
		return -92;
	}


}
